/**
 * 
 */
package ca.usherbrooke.view.slick.jade;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Rectangle;

import ca.usherbrooke.model.equipment.EquipmentModel;

/**
 * @author Ahmed
 * 
 */
public class EquipmentViewJade {
	private final Image image;

	private final Long equipmentId;
	private final IWorldProvider worldProvider;

	public EquipmentViewJade(Image image, Long equipmentId, IWorldProvider world) {
		this.image = image;
		this.equipmentId = equipmentId;
		worldProvider = world;
	}

	public Long getGuid() {
		return equipmentId;
	}

	public EquipmentModel getEquipment() {
		return worldProvider.getWorld().getEquipment(equipmentId);
	}

	public void render(GameContainer container, Graphics g) {
		if (getEquipment() == null) {
			return;
		}
		if (getEquipment().getHolder() == null) {
			Rectangle position = getEquipment().getSize();
			g.drawImage(image, (int) position.getX(), (int) position.getY());
			g.drawString(getEquipment().getGuid().toString(), position.getX(),
					position.getY());
		} else {
			Rectangle position = getEquipment().getSize();
			g.drawString("equip", position.getX(), position.getY());
		}
	}
}
